package com.green.model.manage.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 组织类型
 * @author 
 */
public enum OrgEnum {
	BLOC("集团",1,0),
	COMPANY("城市",2,2),
	REGION("业务部门",4,4),
	FUNCTIONS("职能部门",3,3);
	private OrgEnum(){}
	private OrgEnum(String name,int value,int erpLevel){
		this.name = name;
		this.value = value;
		this.erpLevel = erpLevel;
	}
	private String name;
	private int value;
	private int erpLevel;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getValue() {
		return value;
	}
	public void setValue(int value) {
		this.value = value;
	}
	public int getErpLevel() {
		return erpLevel;
	}
	public void setErpLevel(int erpLevel) {
		this.erpLevel = erpLevel;
	}
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static List toList(){
		OrgEnum[] ary = OrgEnum.values();
		List bank = new ArrayList();
		for(int i=0;i<ary.length;i++){
			Map<String,String> map = new HashMap<String,String>();
			map.put("value", ary[i].toString());
			map.put("name", ary[i].getName());
			bank.add(map);
		}
		return bank;
	}
	public static OrgEnum getByErpLevel(int erpLevel){
		OrgEnum[] ary = OrgEnum.values();
		for(int i=0;i<ary.length;i++){
			OrgEnum oe = ary[i];
			if(erpLevel == oe.getErpLevel()){
				return oe;
			}
		}
		return null;
	}
}
